<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="css/aui.css">
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="js/init.js"></script>
    <title>我的项目</title>
</head>
<body>
<header>
    <a href="my.html" class="f1 head-back"></a>
    <div class="f8">我的项目</div>
    <div class="f1"></div>
</header>
<section class="bg-gray">
    <div class="pad-2">
        <ul id="navbtn" class="bg-blue flex line-h-3 center color-white border-radius-1 hidden">
            <li class="f1 bg-yellow">所有</li>
            <li class="f1 ">已完成</li>
            <li class="f1">进行中</li>
        </ul>

        <div id="itembox">
            <!--所有-->
            <ul class="mar-t-3">
                <!--<li class="border-gray border-radius-1 hidden mar-b-3">-->
                    <!--<div class="bg-gray-l border-b-gray pad-2-3 flex">-->
                        <!--<p class="f1" >永动1号第22期</p>-->
                        <!--<img class="col-1" src="" alt="">-->
                    <!--</div>-->
                    <!--<div class="bg-white pad-3 color-gray line-h-2">-->
                        <!--<p>币种：以太坊（ETH）</p>-->
                        <!--<p>数量：以太坊（ETH）</p>-->
                        <!--<p>收益：以太坊（ETH）</p>-->
                        <!--<p>时间：2019-7-22</p>-->
                        <!--<div>-->
                            <!--状态：-->
                            <!--<span class="pad-1-2 bg-blue color-white font25 border-radius-1">进行中</span>-->
                            <!--<span class="pad-1-2 bg-yellow color-white font25 border-radius-1">未复购</span>-->
                        <!--</div>-->

                    <!--</div>-->
                <!--</li>-->
            </ul>

            <!--已完成-->
            <ul class="mar-t-3 none">

            </ul>

            <!--进行中-->
            <ul class="mar-t-3 none">

            </ul>

        </div>

    </div>
</section>
<!--取消复投弹窗-->
<div class="mask none"></div>
<div id="futoubox" class="mask-box bg-white pad-5 bg-white border-radius-1 center none" style="width: 80%">
    <p class="pad-b-5">确定要取消复投吗？</p>
    <div class="pad-t-2">
        <span id="cancel" class="bg-gray pad-2-5 border-radius-1 mar-r-5" >取消</span>
        <span id="futoubtn" class="bg-blue color-white pad-2-5 border-radius-1" onclick="isfutou()">确定</span>
    </div>
</div>

<script src="js/foot.js"></script>
<script>
    var typeid;
    if(getQueryString('id')){
        typeid = getQueryString('id');
    }
    $("#navbtn li").click(function () {
        var index = $(this).index();
        $(this).addClass('bg-yellow').siblings().removeClass('bg-yellow');
        $("#itembox >ul").eq(index).show().siblings().hide();
    });

    var data;
    new AjaxRequest({
        type: 'post',
        dataType: 'json',
        url: hostUrl + 'index/Mycenter/myitem',
        data: data,
        callback: res => {
            if(res.status == 1){

                function tabcon(type){
                    var list = '';
                    for(var i=0;i<type.length;i++){
                        list += '<li class="border-gray border-radius-1 hidden mar-b-3"><div class="bg-gray-l border-b-gray pad-2-3 flex"><p class="f1" >'+(type[i].circuit_name?type[i].circuit_name:'')+'第'+(type[i].periods_no?type[i].periods_no:'0')+'期</p><img class="col-1" src="" alt=""></div><div class="bg-white pad-3 color-gray line-h-2"><p>币种：'+(type[i].coin_type==1?'以太坊（ETH）':type[i].coin_type==2?'以太经典（ETC）':'无')+'</p><p>数量：'+(type[i].money?type[i].money:'')+'</p><p>收益：'+(type[i].brokerage?type[i].brokerage:'')+'</p><p>时间：'+(type[i].creattime?type[i].creattime:'0000-00-00')+'</p><div>状态：';
                        // 状态1
                        if(type[i].status == 0){
                            list += '<span class="pad-1-2 bg-yellow color-white font25 border-radius-1 mar-r-2">冻结</span>';
                        }
                        if(type[i].status == 1){
                            list += '<span class="pad-1-2 bg-red color-white font25 border-radius-1 mar-r-2">已取消</span>';
                        }
                        if(type[i].status == 2){
                            list += '<span class="pad-1-2 bg-blue color-white font25 border-radius-1 mar-r-2">利润已返</span>';
                        }
                        if(type[i].status == 3){
                            list += '<span class="pad-1-2 bg-yellow color-white font25 border-radius-1 mar-r-2">资金解冻</span>';
                        }
                        if(type[i].status == 4){
                            list += '<span class="pad-1-2 bg-red color-white font25 border-radius-1 mar-r-2">崩线处理</span>';
                        }
                        if(type[i].status == 5){
                            list += '<span class="pad-1-2 bg-blue color-white font25 border-radius-1 mar-r-2">已复购</span>';
                        }
                        if(type[i].status == 6 ){
                            list += '<span class="pad-1-2 bg-red color-white font25 border-radius-1 mar-r-2" >已结束</span>';
                        }


                        // 状态2
                        if(type[i].is_invest == 0 && type[i].status != 6){
                            list += '<span class="pad-1-2 bg-blue color-white font25 border-radius-1 mar-r-2">进行中</span>';
                        }
                        if(type[i].is_invest == 0 && type[i].status == 6){
                            list += '<span class="pad-1-2 bg-blue color-white font25 border-radius-1 mar-r-2">等待中</span>';
                        }
                        if(type[i].is_invest == 1){
                            list += '<span class="pad-1-2 bg-blue color-white font25 border-radius-1 mar-r-2">继续复投</span>';
                        }
                        if(type[i].is_invest == 2){
                            list += '<span class="pad-1-2 bg-red color-white font25 border-radius-1 mar-r-2">取消复投</span>';
                        }
                        if(type[i].is_invest == 3){
                            list += '<span class="pad-1-2 bg-red color-white font25 border-radius-1 mar-r-2">已崩线</span>';
                        }

                        if(type[i].status == 6 && type[i].is_invest == 4){
                            list += '<span class="pad-1-2 bg-blue color-white font25 border-radius-1 mar-r-2" onclick="cancelfutou('+type[i].id+')" >取消复投</span>';

                        }

                        list += '</div></div></li>';
                    }
                    return list;
                };

                $("#itembox >ul:nth-child(1)").html(tabcon(res.data.alllist));
                $("#itembox >ul:nth-child(2)").html(tabcon(res.data.overlist));
                $("#itembox >ul:nth-child(3)").html(tabcon(res.data.processlist));

                if(typeid == 1){
                    $("#navbtn li").eq(0).addClass('bg-yellow').siblings().removeClass('bg-yellow');
                    $("#itembox >ul").eq(0).show().siblings().hide();
                }
                if(typeid == 2){
                    $("#navbtn li").eq(1).addClass('bg-yellow').siblings().removeClass('bg-yellow');
                    $("#itembox >ul").eq(1).show().siblings().hide();
                }
                if(typeid == 3){
                    $("#navbtn li").eq(2).addClass('bg-yellow').siblings().removeClass('bg-yellow');
                    $("#itembox >ul").eq(2).show().siblings().hide();
                }

            }
        }
    });
    
    // 取消复投
    var futou_id;
    function cancelfutou(id) {
        $(".mask").show();
        $("#futoubox").show();
        futou_id = id;

    }
    function isfutou() {
        var data = {
            userid: localStorage.user_id,
            token: localStorage.token,
            snap_id: futou_id,
        };
        new AjaxRequest({
            type: 'post',
            dataType: 'json',
            url: hostUrl + 'index/Crowdfound/cancelperiods',
            data: data,
            callback: res => {

                if(res.status == 1){

                    $(".mask").hide();
                    $(".mask-box").hide();
                    location.reload();

                }else{
                    toast(res.msg);

                }
            }

        });
    }

    $("#cancel").click(function () {
        $(".mask").hide();
        $(".mask-box").hide();
    })


</script>

</body>
</html>